package com.lnt.singleton;

/**
 * @title : 懒汉式单例模式
 * @createDate : 2021-11-04 09:47
 * @creater : LuNanTing
 * @className : LazySingleton
 */
public class LazySingleton {

    // 保证instance在所有线程中同步
    private static volatile LazySingleton instance = null;

    private LazySingleton(){

    }

    public static synchronized LazySingleton getInstance(){
        if(instance == null){
            instance = new LazySingleton();
        }
        return instance;
    }
}
